package com.tansun.easycare.rule.rulemange.service;

import java.util.List;
import java.util.Map;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageInfo;
import com.tansun.easycare.rule.common.ReferenceModel;
import com.tansun.easycare.rule.common.model.BaseModel;
import com.tansun.easycare.rule.common.service.RuleBaseService;
import com.tansun.easycare.rule.exception.BizException;
import com.tansun.easycare.rule.rulemange.entity.RuleManage;
import com.tansun.easycare.rule.rulemange.model.RuleManageVO;
import com.tansun.easycare.rule.ruleversion.entity.RuleVersioninfo;

public interface RuleManageService extends RuleBaseService<RuleManage> {

    /**
     * 根据决策表信息保存规则管理信息
     */
    RuleManage saveOrUpdate(RuleManage decisionTbl) throws BizException;
    
    /**
     * 审批后调用，更新有效版本
     */
    RuleManage updateActiveVersion(List<String> list) throws BizException;

    /**
     * 通过模型ID获取数据
     */
    RuleManage getById(String indexId) throws BizException;

    List<RuleManage> searchRuleTable(List<RuleManage> list, BaseModel param);

    /**
     * 查找规则信息VO列表
     */
    List<RuleManageVO> findRuleManageVO(Map<String, Object> map);

    List<RuleManageVO> findRuleManageVO(BaseModel condition);

    /**
     * 查询分页规则信息VO
     */
    PageInfo<RuleManageVO> findRuleManageVO(Page<RuleManageVO> page, RuleManageVO ruleManage);


    List<RuleManageVO> findRuleManageVO(RuleManageVO condition);

    /**
     * 更新授权信息
     */

    void updateAuthority(String id, String projectCode, String authTypeValue, String loginNames, String currLoginName) throws BizException;


    /**
     * 判断规则管理信息是否存在
     */
    boolean isExists(RuleManage queryManage) throws BizException;

    /**
     * 查询页面显示主要组件的RuleManage
     * @param queryManage
     * @return
     */
    List<RuleManage> findMainManageList(RuleManage queryManage);
    
    /**
     * 代理服务类
     */
    void setRuleBaseService(RuleBaseService<?> ruleBaseService);

    /**
     * 规则版本发布
     */
    void publicRule(String managerId) throws BizException;

    /**
     * 规则版本回退
     */
    void publicRule(String managerId, String version) throws BizException;

    String generalCodeByType(String type, String projectCode) throws BizException;

    /**
     * 删除规则模型（将状态标志位至0）
     * 删除前检查被引用情况，如被引用，不能删除
     */
    public List<ReferenceModel> delete(String manageId,String projectCode) throws BizException ;

    /**
     * 版本Copy
     */
    void copyRule(String manageId,String rankRelationId) throws BizException;

    /**
     * 根据项目编号，规则模型编号查找规则模型
     */
    RuleManage findByCode(String code, String projectCode) throws BizException;
    
    /**
     * 检查当前导入模型是否存在，如果存在进行更新
     * @param cur
     * @param modelType
     */
    void checkImport(RuleManage cur,String modelType);
    /**
     * 根据本身模型manage查询关联模型的manage
     * @param ruleManage
     * @return
     */
    List<RuleManage> findListByRefManage(RuleManage ruleManage);
    
    /**
     * 根据id查询
     * @param ids
     * @return
     */
    List<RuleManage> findListByIds(List<String> ids);
    
    /**
     * 更新关联层级ID（初始化）
     * @param condition
     * @return
     */
    int updateRankId(RuleManage condition);
    /**
     * 根据条件获取数据量
     * @param condition
     * @return
     */
    int countList(RuleManage condition);
    /**
     * 根据条件获取数据量
     * @param ruleManage
     * @return
     */
    int countListFindName(RuleManage ruleManage,String modelType);
    
    
    RuleVersioninfo  findRuleVersionInfo(String  projectCode,String  manageId);
    

}
